package com.loto.insurance.framework;

public enum InsuranceStatusEnum {
  EFFECT("已生效", 0), INVALID("已作废", 1), CANCELED("已撤销", 2);

  private String name;
  private int index;

  private InsuranceStatusEnum(String name, int index) {
	this.name = name;
	this.index = index;
  }

  public static String getName(int index) {
	for (InsuranceStatusEnum c : InsuranceStatusEnum.values()) {
	  if (c.getIndex() == index) {
		return c.name;
	  }
	}
	return null;
  }

  public static int getIndex(String name) {
	for (InsuranceStatusEnum c : InsuranceStatusEnum.values()) {
	  if (c.getName() == name) {
		return c.index;
	  }
	}
	return 0;
  }

  public String getName() {
	return name;
  }

  public void setName(String name) {
	this.name = name;
  }

  public int getIndex() {
	return index;
  }

  public void setIndex(int index) {
	this.index = index;
  }

  @Override
  public String toString() {
	return this.name;
  }
}
